home *** CD-ROM | disk | FTP | other *** search
Wrap
Listing 1 #include "stdio.h" /******************************************************************************/ /*---------------------------- The TOUCH utility -----------------------------*/รจ/******************************************************************************/ /* */ /* Name: bump Version: 1.0 */ /* */ /* Last Edit: 03/21/86 Compiler: Lattice C, v2.15d */ /* */ /* Purpose: Change a file or list of files time and date stamp to the */ /* current date and time. */ /* */ /******************************************************************************/ /*------------------ Copyright 1985 & 1986, by Gary Elfring ------------------*/ main(argc,argv) int argc; char *argv[]; { extern FILE *fopen(); FILE *ptr; int i; char buf[2]; /*---------- If only one argument, tell them how to use the program ----------*/ if (argc == 1) { printf("USE --> touch file1.ext file2.ext ... fileN.ext{cr}\n"); exit(1); } /*------------------------- For each passed argument -------------------------*/ for (i = 1; i < argc; ++i) { /*-------------------- Open the file for read / write --------------------*/ if ((ptr = fopen(argv[i],"rb+")) == NULL) { printf("Error: can not open %s\n",argv[i]); exit(2); } /*---------------------------- Read in 1 byte ----------------------------*/ fread(buf,1,1,ptr); /*-------------- Rewind the file pointer back to beginning ---------------*/ fseek(ptr,0L,0); /*-------------- Write the byte out (force redate of file) ---------------*/ fwrite(buf,1,1,ptr); /*----------------- Close the file and move to the next ------------------*/ fclose(ptr); } }